<?php
/**
 * @author Ngo Minh Tri <minhtri2711@gmail.com>
 */
require_once APPPATH . "controllers/cmsbase.php";
class cms_site_content extends CmsBase {

	var $_require_login = true;
	var $controller_js_path = 'cms_site_content/main';

	function __construct() {
		parent :: __construct();
		// Check permission
		parent::_check_permission('pms_node');
		$this->load->model('Model_c1', 'model_c1');
		$this->load->model('Model_nav', 'model_nav');
	}

	/**
	 *
	 *
	 * @return
	 */
	function init($level, $nav_id){
		$this->_level = $level;
		$this->_nav_id = $nav_id;
	}

	/**
	 *
	 *
	 */
	function index($level = 1, $nav_id = 0) {
		$this->init($level, $nav_id);
		$templates = $this->config->item('templates');
		// get c1 list
		$c1_list = $this->model_c1->find_by_nodeid($nav_id);
		return $this->_render_my_view(array('c' => 'Edit Site Information', 'level' => $this->_level, 'nav_id' => $this->_nav_id, 'c1_list' => $c1_list, 'template_array' => $templates));
	}

	/**
	 *
	 *
	 */
	function add($level = 1, $nav_id = 0) {
		$this->init($level, $nav_id);
		$templates = $this->config->item('templates');
		$data = '<ul id="template-list">';
		foreach ($templates as $item) {
			$data .= '<li><a href="'.site_url(array('d' => 'templates', 'c' => $item['controller'], 'm' => 'add', 'level' => $level, 'nav_id' => $nav_id)) . '" style="background-image: url(public/admin/images/' . $item['avatar'] . ')">' . $item['name'] . '</a></li>';
		}
		$data .= '</ul>';

		$this->main_content = $this->load->view($this->controller_name . '/' . 'add', $this->_mereg(array (
			'c' => 'Add site content', 'templates' => $data)), true);
		return $this->_render();
	}

	function edit() {

	}
}
?>
